import requests
from common.get_header_A import get_header
from common.json_read_tuplelist import json_read
from config import BASE_DIR

class UserGL:
    @classmethod
    def assert_user(cls,resp,code_status,success,message):
        assert resp.status_code == code_status
        assert resp.json().get("success") is success
        assert resp.json().get("message") == message
    @classmethod
    def user_zc(cls,data):
        resp = requests.post(url="http://5912.org:6666/api/register",headers={"Content-Type":"application/json"},json=data)
        return resp
    @classmethod
    def user_dl(cls,data):
        resp = requests.post(url="http://5912.org:6666/api/login",headers={"Content-Type":"application/json"},json=data)
        return  resp

class Address:
    @classmethod
    def assert_address(cls,resp,success,message):
        assert resp.json().get("success") is success
        assert resp.json().get("message") == message

    @classmethod
    def assert_address_select(cls, resp, success):
        assert resp.json().get("success") is success
    @classmethod
    def add_address(cls,data):
        resp = requests.post(url="http://5912.org:6666/api/address/add",headers={"Content-Type":"application/json","Authorization":get_header()},json=data)
        return  resp
    @classmethod
    def update_address(cls,data):
        resp = requests.post(url="http://5912.org:6666/api/address/update", headers={"Content-Type": "application/json","Authorization":get_header()}, json=data)
        return  resp
    @classmethod
    def delete_address(cls,data):
        resp = requests.post(url="http://5912.org:6666/api/address/delete", headers={"Content-Type": "application/json","Authorization":get_header()}, json=data)
        return  resp
    @classmethod
    def get_address(cls,data):
        resp = requests.post(url="http://5912.org:6666/api/address/list", headers={"Content-Type": "application/json","Authorization":get_header()}, json=data)
        return  resp
    @classmethod
    def mr_address(cls,data):
        resp = requests.post(url="http://5912.org:6666/api/address/set_default", headers={"Content-Type": "application/json","Authorization":get_header()}, json=data)
        return  resp
if __name__ == '__main__':

    print(json_read('../data/zcdata.json'))